package com.mine.site.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.mine.site.dao.UserDao;
import com.mine.site.model.User;

/**
 * Servlet implementation class panduan
 */
@WebServlet("/panduan")
public class panduan extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public panduan() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("UTF-8");
		response.setContentType("utf-8");
		
		
		String method = request.getParameter("abc");
		if("clnz".equals(method)){
			this.CommodityServlet(request, response);
		}else if("clnanz".equals(method)){
			this.CommodityServlet(request, response);
		}
		else{
			this.list(request, response);
		}
	}


	private void CommodityServlet(HttpServletRequest request,
			HttpServletResponse response) {
		// TODO Auto-generated method stub
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doGet(request, response);
	}
	
	
	private void list(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
		UserDao dao = new UserDao();
		List<User> users = dao.findAll();
		request.setAttribute("userList", users);
		
		request.getRequestDispatcher("bsindex.jsp").forward(request, response);
	}
}
